package com.atguigu.juc.cf;

import org.junit.jupiter.api.Test;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author yanglin
 * @create 2023-12-28 9:47 星期四
 * description:
 */
public class CompletableFutureDemo {
    
    @Test
    public void testCompletableFuture() throws ExecutionException, InterruptedException {
        //多线程，有返回，异步任务（异步多线程）
        FutureTask<String> futureTask = new FutureTask<>(new MyThread2());
        Thread t1 = new Thread(futureTask, "t1");
        t1.start();

        //获取Callable的返回值
        System.out.println(futureTask.get());

    }
    
}
